#include "MessageLogIn.h"
#include "MessagesDefs.h"




MessageLogIn::MessageLogIn(std::string id)
:	Message(MessagesDefs::k_MESSAGE_LOGIN, id)
{	
	setData("", 0, 0, 0);
}

MessageLogIn::~MessageLogIn()
{

}

void MessageLogIn::setData(std::string name, int health, double posX, double posY)
{
	m_data->seek(MSG_OFFSET_ID);
	m_data->readUTF(); // Skip id

	m_data->writeUTF(name);
	m_data->writeInt(health);
	m_data->writeDouble(posX);
	m_data->writeDouble(posY);
}

std::string MessageLogIn::getName()
{
	m_data->seek(MSG_OFFSET_ID);
	m_data->readUTF();	// Skip id;
	
	return m_data->readUTF();
}

int MessageLogIn::getHealth()
{
	m_data->seek(MSG_OFFSET_ID);
	m_data->readUTF();	// Skip id;
	m_data->readUTF();	// Skip name;
	
	return m_data->readInt();
}

double MessageLogIn::getPosX()
{
	m_data->seek(MSG_OFFSET_ID);
	m_data->readUTF();	// Skip id;
	m_data->readUTF();	// Skip name;
	m_data->readInt();	// Skip health;
	
	return m_data->readDouble();
}

double MessageLogIn::getPosY()
{
	m_data->seek(MSG_OFFSET_ID);
	m_data->readUTF();		// Skip id;
	m_data->readUTF();		// Skip name;
	m_data->readInt();		// Skip health;
	m_data->readDouble();	// Skip posX;
	
	return m_data->readDouble();
}